package com.springboot.springbootlogindemo.controller;


import com.springboot.springbootlogindemo.domain.Comments;
import com.springboot.springbootlogindemo.service.CommentsService;
import com.springboot.springbootlogindemo.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController//表明此类是一个控制器类,且返回的不是视图，而是数据
@RequestMapping("/comments")//控制器类的基路由
public class CommentsController {


    @Resource
    private CommentsService commentsService;


    /**
     * 增加评论
     * @param comments
     * @return
     */
    @PostMapping("/addComment")
    public Result addComment(@RequestBody Comments comments){
        return commentsService.addComment(comments);
    }


    /**
     * 删除评论
     * @param commentId
     * @return
     */
    @PostMapping("/deleteComment")
    public Result deleteComment(@RequestParam Long commentId){
        return commentsService.deleteComment(commentId);
    }

    /**
     * 展示该评论的相关评论
     * @param commentId
     * @return
     */
    @GetMapping("/showComments")
    public Result showComments(@RequestBody Long commentId){
        return commentsService.showCommentComments(commentId);
    }
}
